package com.evil.kingdom.listener;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.evil.kingdom.listener.event.SecondTickEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 秒-时钟监听器
 *
 * @author LY
 * @date 2024/5/1810:18
 */
@Slf4j
@Component
public class SecondTickListener implements ApplicationListener<SecondTickEvent> {

    @Override
    public void onApplicationEvent(SecondTickEvent event) {
        LocalDateTime time = event.getTime();
        // 处理每秒事件
        log.debug("Second ticked at: {}", LocalDateTimeUtil.formatNormal(time));
    }
}
